<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-form ref="form" :model="t_item" :rules="rules" label-width="100px" id="mvcfm">
      <el-button @click="gotoPage('/psi/supplychainmana/WarehouseRegion?'+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>返回</el-button>
      <div class="form-unit">
        <span class="mvc-title-left"> 区域 </span>
      </div>
      <div>
        <el-row>
          <el-col :span="24">
            <el-form-item label="仓库" prop="">
              {{t_item.firm_name}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="区域" prop="">
              {{t_item.name}}
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <el-button @click="popWareRowsUp('')" type='success' size="mini"><i class='fa fa-edit'></i>修改</el-button>
      <div class="form-unit">
        <span class="mvc-title-left"> 行排格 </span>
      </div>
      <el-table :data="s_district">
        <el-table-column label="行号" prop="district_rows">
        </el-table-column>
        <el-table-column label="排号" prop="district_lines">
        </el-table-column>
        <el-table-column label="格号" prop="district_racks">
        </el-table-column>
      </el-table>
      <el-button @click="popWareStaffChoice('')" type='success' size="mini"><i class='fa fa-plus'></i>增加</el-button>
      <div class="form-unit">
        <span class="mvc-title-left"> 库管员 </span>
      </div>
      <el-table :data="s_staff">
        <el-table-column label="操作" align="center" width='100' type=''>
          <template slot-scope="scope">
            <el-dropdown trigger="click">
              <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item>
                  <el-link @click="d_staff('&CMIDstaff_id='+scope.row.staff_id+'')">移除</el-link>
                </el-dropdown-item>
                <el-dropdown-item>
                  <el-link @click="u_staff('&CMID3='+scope.row.staff_id+'')">设置为默认</el-link>
                </el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </template>
        </el-table-column>
        <el-table-column label="姓名" prop="contact_name">
        </el-table-column>
        <el-table-column label="联系方式" prop="relation_tel">
        </el-table-column>
        <el-table-column label="状态" prop="staff_state">
          <template slot-scope="scope">
            {{getValueName("正常=0,默认=1",scope.row.staff_state)}}
          </template>
        </el-table-column>
      </el-table>
    </el-form>
    <el-dialog :visible.sync="WareRowsUpVisible" append-to-body>
      <WareRowsUp v-if="WareRowsUpVisible" ref="WareRowsUp" :popparams="popparams"> </WareRowsUp>
    </el-dialog>
    <el-dialog :visible.sync="WareStaffChoiceVisible" append-to-body>
      <WareStaffChoice v-if="WareStaffChoiceVisible" ref="WareStaffChoice" :popparams="popparams"> </WareStaffChoice>
    </el-dialog>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import WareRowsUp from "@/views/psi/supplychainmana/WareRowsUp";
  import WareStaffChoice from "@/views/psi/supplychainmana/WareStaffChoice";
  export default {
    name: 'WarehouseRegionUp',
    components: {
      WareRowsUp,
      WareStaffChoice,
    },
    props: ['popparams'],
    data() {
      return {
        WareRowsUpVisible: false,
        WareRowsUpValue: null,
        WareRowsUpDesc: null,
        WareStaffChoiceVisible: false,
        WareStaffChoiceValue: null,
        WareStaffChoiceDesc: null,
        vueparams: this.getVUEParams(""),
        t_item: {
          firm_name: null,
          name: null,
        },
        s_district: [],
        s_staff: [],
        loading: false,
        rules: {}
      }
    },
    created() {
      this.getData();
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/psi/supplychainmana/WarehouseAction/warehouseRegionUp?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      d_staff(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/psi/supplychainmana/WarehouseAction/d_staff?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      u_staff(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/psi/supplychainmana/WarehouseAction/u_staff?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      popWareRowsUp(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.WareRowsUpVisible = !this.WareRowsUpVisible;
      },
      popWareStaffChoice(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.WareStaffChoiceVisible = !this.WareStaffChoiceVisible;
      },
    },
  }
</script>
